/**
 * 
 */
package com.witframework.web.extremetable;

import java.util.Iterator;
import java.util.List;

import org.extremecomponents.table.bean.Column;
import org.extremecomponents.table.core.TableModel;
import org.extremecomponents.table.view.html.TableBuilder;
import org.extremecomponents.util.HtmlBuilder;

/**
 * @author wuxinyang
 * Jun 29, 2009 11:46:14 AM
 * 
 */
public class WsTableBuilder extends TableBuilder{
	
	public WsTableBuilder(TableModel model) {
		super(model);
	}
	/**
	 * @param html
	 * @param model
	 */
	public WsTableBuilder(HtmlBuilder html, TableModel model) {
		super(html, model);		
	}	
	public void theadStart() {
		String fixHeader=getTableModel().getTableHandler().getTable().getAttributeAsString("fixHeader");
		getHtmlBuilder().thead(1);
		if(fixHeader!=null&&fixHeader.equals("true"))
			getHtmlBuilder().styleClass("fixedHeader").id("fixedHeader");
		getHtmlBuilder().close();
    }
	public void headerRow() {
		getHtmlBuilder().tr(1);		
		getHtmlBuilder().close();
        List columns = getTableModel().getColumnHandler().getHeaderColumns();
        for (Iterator iter = columns.iterator(); iter.hasNext();) {
            Column column = (Column) iter.next();
            getHtmlBuilder().append(column.getCellDisplay());
        }

        getHtmlBuilder().trEnd(1);
    }
	 public void tbodyStart() {
		 String fixHeader=getTableModel().getTableHandler().getTable().getAttributeAsString("fixHeader");
		 getHtmlBuilder().tbody(1);
		 if(fixHeader!=null&&fixHeader.equals("true"))
			 getHtmlBuilder().styleClass("scrollContent");
		 getHtmlBuilder().close();
	 }
}
